function myRandom(i, low, high)
{
	var a = 16645.0;
	var c = 10139042.0;
	var m = 42949672.0;
	
	RandomArray[i] = (a*RandomArray[i] + c)%m;
	return ((high - low) * (RandomArray[i] / m)) + low;
}

//Returns a velocity to apply in X and Z
function adjustVelocity(i, low, high)
{
	return ((((((2 * myRandom(i, low,high)) + 1) *myRandom(i, low,high)) + 1) * 0.005) - (((((2 * myRandom(i, low,high)) + 1) * myRandom(i, low,high)) + 1) * 0.005))/50;
}

//Returns an Acceleration to apply in Y
function adjustAccel(i, low, high)
{
	return (((((5 * myRandom(i, low,high)) + 5) * myRandom(i, low,high)) + 1) * 0.02)/100;
}

//Return a random color in the specified range (0-255) for a single channel
function randomColor(min,max)
{
	return Math.floor(rand(min,max))/255
}

//Give a particle new values
function genParticle(i, nonMoveAttrib) 
{
	VertexArray[i*3] = startingPos[0];
	VertexArray[i*3+1] = startingPos[1];
	VertexArray[i*3+2] = startingPos[2];
	
	VelocityArray[i*4] = adjustVelocity(i,2,14);
	VelocityArray[i*4+1] = adjustAccel(i,2,11);
	VelocityArray[i*4+2] = adjustVelocity(i,2,14);
	VelocityArray[i*4+3] = 0.0015;
	
	if (nonMoveAttrib == true) {	
		ColorArray[i*3] = randomColor(0,255);
		ColorArray[i*3+1] = randomColor(0,80);
		ColorArray[i*3+2] = randomColor(0,80);
	}
}

//Use existing values to update the particle's information
function updateParticle(i)
{
	VertexArray[i*3+1] = VertexArray[i*3+1] + VelocityArray[i*4+1] - VelocityArray[i*4+3];
	VelocityArray[i*4+3] = VelocityArray[i*4+3] + 0.0015;
	VertexArray[i*3] = VertexArray[i*3] + VelocityArray[i*4];
	VertexArray[i*3+2] = VertexArray[i*3+2] + VelocityArray[i*4+2];
}